package com.wtx.chapter01;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @description: 定制服务端的初始化器
 * @author: wtx
 * @createDate: 2020/5/28
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {

    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast("httpServerCodec",new HttpServerCodec()); //添加HttpServerCodec处理器
        pipeline.addLast("testHttpServerHandler",new TestHttpServerHandler());   //添加自定义handler
    }
}
